<?php

require ('class/config.php');

$query = "SELECT kegiatan.*, kabkota.nama_kabkota as `kabupaten`, sektoral.nama_sektoral as `sektoral`, sektoral.icon as `ikon` FROM `kegiatan` 
					  JOIN `kabkota`  ON kabkota.idkabkota = kegiatan.idkabkota
					  JOIN `sektoral` ON sektoral.idsektoral = kegiatan.idsektoral
					  ORDER BY `idkegiatan`";
$data = mysql_query($query);

$json = '{"kimrum": {';
$json .= '"kegiatan":[ ';
while($x = mysql_fetch_array($data)){
    $json .= '{';
    $json .= '"idkegiatan":"'.$x['idkegiatan'].'",
        "nama_kegiatan":"'.htmlspecialchars($x['nama_kegiatan']).'",
        "sektoral":"'.$x['sektoral'].'",
        "ikon":"'.$x['ikon'].'",
        "x":"'.$x['lat'].'",
        "y":"'.$x['long'].'"
    },';
}
$json = substr($json,0,strlen($json)-1);
$json .= ']';
$json .= '}}';
echo $json;

?>
